/**
 * The MIT License
 * <p>
 * Copyright (c) 2017
 */
package com.seelyn.flow.engine;

import com.seelyn.flow.work.WorkReport;
import com.seelyn.flow.workflow.WorkFlow;

import java.util.logging.Level;
import java.util.logging.Logger;

class WorkFlowEngineImpl implements WorkFlowEngine {

    private static final Logger LOGGER = Logger.getLogger(WorkFlowEngineImpl.class.getName());

    private final WorkFlowParams workFlowParams;

    public WorkFlowEngineImpl(WorkFlowParams workFlowParams) {
        this.workFlowParams = workFlowParams;
    }

    @Override
    public WorkReport run(WorkFlow workFlow) {
        LOGGER.log(Level.INFO, "Running workflow ''{0}''", workFlow.getName());
        workFlow.setParams(workFlowParams);
        return workFlow.call();
    }

}
